package com.gexiaobao.pigeon.ui.fragment.setting

import android.os.Bundle
import com.gexiaobao.pigeon.app.base.BaseFragment
import com.gexiaobao.pigeon.app.eventViewModel
import com.gexiaobao.pigeon.app.ext.Constant
import com.gexiaobao.pigeon.app.ext.initClose
import com.gexiaobao.pigeon.app.util.KvUtils
import com.gexiaobao.pigeon.databinding.FragmentRecommendationManagementBinding
import com.gexiaobao.pigeon.viewmodel.SettingViewModel
import me.hgj.jetpackmvvm.ext.nav

/**
 * @Author      : hxw
 * @Date        : 2023/12/28 11:22
 * @Describe    : 推荐管理
 */
class FragmentRecommendationManagement : BaseFragment<SettingViewModel, FragmentRecommendationManagementBinding>() {
    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.includeBar.toolbar.initClose("个性化内容推荐") {
            nav().navigateUp()
        }
        val isRecommend = KvUtils.decodeBooleanTure(Constant.IS_RECOMMENDATION, true)
        mDatabind.switchRecommendation.isChecked = isRecommend

        mDatabind.switchRecommendation.setOnCheckedChangeListener { _, isChecked ->
            KvUtils.encode(Constant.IS_RECOMMENDATION, isChecked)
        }
    }
}